package com.paic.mhis.hcpms.common.community.util;

import com.itextpdf.text.Paragraph;
import java.io.IOException;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.BaseFont;


public class PdfParagraph extends Paragraph {
	 private static final long serialVersionUID = -244970043180837974L;
	 

	   public PdfParagraph(String content) {
	      super(content, getChineseFont(12, false));
	   }
	 

	   public PdfParagraph(String content, int fontSize, boolean isBold) {
	      super(content, getChineseFont(fontSize, isBold));
	   }
	 

	   // 设置字体-返回中文字体
	   protected static Font getChineseFont(int nfontsize, boolean isBold) {
	      BaseFont bfChinese;
	      Font fontChinese = null;
	      try {
	         bfChinese = BaseFont.createFont("c://windows//fonts//simsun.ttc,1",
	                BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
	         if (isBold) {
	            fontChinese = new Font(bfChinese, nfontsize, Font.BOLD);
	         } else {
	            fontChinese = new Font(bfChinese, nfontsize, Font.NORMAL);
	         }
	      } catch (DocumentException e) {
	         // TODO Auto-generated catch block
	         e.printStackTrace();
	      } catch (IOException e) {
	         // TODO Auto-generated catch block
	         e.printStackTrace();
	      }
	      return fontChinese;
	   }
	 

	 

	   // 转化中文
	   protected Chunk ChangeChunk(String str, int nfontsize, boolean isBold)
	         throws IOException, BadElementException, DocumentException {
	      Font FontChinese = getChineseFont(nfontsize, isBold);
	      Chunk chunk = new Chunk(str, FontChinese);
	      return chunk;
	   }
	 

	   // 转化中文
	   protected Phrase ChangeChinese(String str, int nfontsize, boolean isBold)
	         throws IOException, BadElementException, DocumentException {
	      Font FontChinese = getChineseFont(nfontsize, isBold);
	      Phrase ph = new Phrase(str, FontChinese);
	      return ph;
	   }

}
